Skip to content

feat: add min search length control #3242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 15, 2025
Merged

feat: add min search length control #3242

merged 4 commits into from
Jun 15, 2025

Conversation

yajra
Copy link
Owner

@yajra yajra commented Jun 3, 2025

fix: #3241

Usage

    public function dataTable(QueryBuilder $query): EloquentDataTable
    {
        return (new EloquentDataTable($query))
            ->minSearchLength(5)
            ->setRowId('id');
    }

Response

{
    "draw": 2,
    "recordsTotal": 0,
    "recordsFiltered": 0,
    "data": [],
    "error": "Exception Message:\n\nPlease enter at least 5 characters to search."
}

Copy link

sonarqubecloud bot commented Jun 3, 2025

@yajra
Copy link
Owner Author

yajra commented Jun 3, 2025

Example JS to show the custom error message using toastr:

$.fn.DataTable.ext.errMode = function(settings, techNote, message) {
    const errorMessage = '<p class="text-center my-4 font-semibold">'+message.substring(message.lastIndexOf('\n') + 1).trim()+'</p>';
    const errorTitle = 'An error occurred while loading the table';
    toastr['error'](errorMessage, errorTitle, {
        positionClass: "toast-top-center mt-32",
        closeButton: true,
        progressBar: true,
    });
};

Output

image

@yajra yajra merged commit 85fd9d5 into master Jun 15, 2025
2 checks passed
@yajra yajra deleted the min-search-length branch June 15, 2025 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Native support for minimum search length
1 participant